/**
 Copyright (C) 2013 Yuyao Liang

 This source code is release under the BSD License.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.

 Created on Nov 1, 2013 9:55:37 AM
 */
package com.googlecode.backtest.rule.queue;

import com.google.srclib.stock.Messages;
import com.googlecode.backtest.controller.IBackTestController;
import com.googlecode.backtest.dataset.provider.IDataProvider;

/**
 * @author lianyuy
 * 
 */
public abstract class ForLoopAlgorithmQueue<T, S, V, P> implements
		IForLoopAlgorithmQueue<T, S, V, P> {
	private final String ID = getClass().getName();
	private final String VERSION = Messages
			.getString("ForLoopAlgorithmQueue.VERSION"); //$NON-NLS-1$
	private final String Key = Messages.getString("ForLoopAlgorithmQueue.key"); //$NON-NLS-1$

	protected P start;
	protected P stop;
	protected P step;
	protected IBackTestController<T, S, V> controller = null;

	/**
	 * @param start
	 * @param stop
	 * @param step
	 */
	protected ForLoopAlgorithmQueue(P start, P stop, P step) {
		super();
		this.start = start;
		this.stop = stop;
		this.step = step;
	}

	public ForLoopAlgorithmQueue(P start, P stop, P step,
			IBackTestController<T, S, V> controller) {
		this(start, stop, step);
		this.controller = controller;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IForLoopAlgorithmQueue#getStart()
	 */
	@Override
	public P getStart() {
		return start;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IForLoopAlgorithmQueue#getStop()
	 */
	@Override
	public P getStop() {
		return stop;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IForLoopAlgorithmQueue#getStep()
	 */
	@Override
	public P getStep() {
		return step;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.srclib.base.IDable#getID()
	 */
	@Override
	public String getID() {
		return ID;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.google.srclib.base.Versionable#getVersion()
	 */
	@Override
	public String getVersion() {
		return VERSION;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IAlgorithm#getKey()
	 */
	@Override
	public String getKey() {
		return Key;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.googlecode.backtest.rule.IBackTestAlgorithm#isValid()
	 */
	@Override
	public boolean isValid() {
		return controller != null;
	}


}
